package view;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

public class BoardPanel extends JPanel{
	private static final long serialVersionUID = 4681830567917333591L;
	TileComponent firstTile;
	public TileComponent currentTile=null;
	
	public JPanel drawingPane;
	public Dimension area;
	
	public BoardPanel(){
		super(new BorderLayout());
		area = new Dimension(0,0);
		this.setBounds(0, 0, 800, 600);
				
		drawingPane = new DrawingPane();
		JScrollPane scroller = new JScrollPane(drawingPane);
        scroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        add(scroller, BorderLayout.CENTER);
	}
		
	public class DrawingPane extends JPanel{
		private static final long serialVersionUID = 1L;
		public DrawingPane(){
            super(null);
            Color backgroundColor = new Color(22,161,55);
            this.setBackground(backgroundColor);
        }
		
		
		@Override
		protected void paintComponent(Graphics g) {
			super.paintComponent(g);
			if(currentTile!=null){
				currentTile.showPosition =true;
				g.drawImage(currentTile.getTile().getImage(),currentTile.getX(), currentTile.getY(), currentTile.getWidth(), currentTile.getHeight(), null);
			}	
			
		}

		public void translateAllComponent(int dx, int dy){
			this.setSize(this.getWidth()+dx, this.getHeight()+dy);
			for(int i=0;i<this.getComponentCount();i++){
				Component cmp = this.getComponent(i);
				cmp.setLocation(cmp.getX()+dx, cmp.getY()+dy);
			}	
		}
	}
	
	
	
	
	
	
	
	
	
	
	
}	